#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int evalRPN(vector<string>& tokens)
    {
        stack<int>s1;
        int i = 0;
        while (i < tokens.size())
        {
            if (tokens[i] == "+" || tokens[i] == "-" || tokens[i] == "*" || tokens[i] == "/")
            {
                int right = s1.top();
                s1.pop();
                int left = s1.top();
                s1.pop();

                switch (tokens[i][0])
                {
                case '+':
                    s1.push(left + right);
                    break;

                case '-':
                    s1.push(left - right);
                    break;

                case '*':
                    s1.push(left * right);
                    break;

                case '/':
                    s1.push(left / right);
                    break;

                }
                // cout<<s1.top()<<endl;

            }
            else
            {
                s1.push(stoi(tokens[i]));
            }
            cout << s1.top() << endl;
            i++;
        }
        return s1.top();
    }
};